package nuist.hanniko.stu.webbackend.dao.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class TokenDAO {
    @Autowired
    private RedisTemplate redisTemplate;

    private static final String TOKEN_KEY = "token_store";

    public Object getToken(String uid) {
        return redisTemplate.opsForHash().get(TOKEN_KEY, uid);
    }

    public void createToken(String uid, String token) {
        redisTemplate.opsForHash().put(TOKEN_KEY, uid, token);
    }

    public void updateToken(String uid, String token) {
        createToken(uid, token);
    }
}
